local chunyi = fk.CreateSkill {
  name = "lvshi__chunyi",
  tags = {"Phase"},
}

Fk:loadTranslationTable{
  ["lvshi__chunyi"] = "醇义",
  [":lvshi__chunyi"] = "阶段技，你可与一名其他角色同时选择一至两张手牌交换，若数量相同/不同，则你可视为使用【酒】/火【杀】。",
  ["#lvshi__chunyi"] = "醇义：请选择至多两张手牌和一名角色",
  ["#lvshi_chunyi-ask"] = "醇义：请选择至多两张手牌和%src交换",
  ["$lvshi__chunyi1"] = "醉里披甲执坚，梦中杀敌破阵。",
  ["$lvshi__chunyi2"] = "醇醪须与明君饮，沙场无还亦不悔。",
}


chunyi:addEffect("active", {
  anim_type = "offensive",
  prompt = "#lvshi__chunyi",
  min_card_num = 1,
  max_card_num = 2,
  target_num = 1,
  max_phase_use_time = 1,
  card_filter = function(self, player, to_select, selected)
    return table.contains(player:getCardIds("h"), to_select)
  end,
  target_filter = function(self, player, to_select, selected, selected_cards)
    return to_select ~= player and not to_select:isKongcheng()
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local cards = room:askToCards(target, {
      min_num = 1,
      max_num = 2,
      skill_name = chunyi.name,
      prompt = "#lvshi_chunyi-ask:"..player.id,
      cancelable = false,
    })
    local pattern = "lvs_fire__slash"
    if #effect.cards == #cards then
      pattern = "analeptic"
    end
    room:swapCards(player, {
      {player, effect.cards},
      {target, cards},
    }, chunyi.name)
    local params = {
      name = pattern,
      skill_name = chunyi.name,
    }
    room:askToUseVirtualCard(player, params)
  end,
})

return chunyi
